asm
  ld sp,$87FF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"
#include "./library/charmap01.bas"

dim eee as uinteger at $8610
dim seed as uinteger at $8612
dim ee1 as uinteger at $8614
dim ee2 as uinteger at $8616
dim ee3 as uinteger at $8618
dim eep as uinteger at $861A
dim ex1 as uinteger at $861C
dim ey1 as uinteger at $861E
dim ep2 as uinteger at $8620

out 0,$07

sub dottorikunputchar(txp1 as uinteger,typ1 as uinteger,tch1 as uinteger,tad1 as uinteger,txr1 as ubyte):
  dim tpl1 as uinteger at $8600
  for tpl1=0 to 7
    poke $8000+txp1+(typ1*128)+(tpl1*16),(peek(tad1+(tch1*8)+tpl1)) bxor txr1
    next
  end sub

seed=0

for ee1=0 to 11
  for ee2=0 to 15
    seed=smsrnd(seed)
    dottorikunputchar(ee2,ee1,96+(seed mod 9),@charmap01-256,$FF)
    next
    next

for ee1=0 to 7
  for ee2=0 to 7
    seed=smsrnd(seed)
    dottorikunputchar(ee2+7,ee1+3,32+(ee1*8)+ee2,@charmap01-256,$FF)
    next
    next

eep=$07
eee=0
do

dottorikunputchar(1,1,48+(int(eee/100) mod 10),@charmap01-256,$FF)
dottorikunputchar(2,1,48+(int(eee/10) mod 10),@charmap01-256,$FF)
dottorikunputchar(3,1,48+(eee mod 10),@charmap01-256,$FF)

ee1=in(0) bxor 255
dottorikunputchar(1,3,48+(int(ee1/100) mod 10),@charmap01-256,$FF)
dottorikunputchar(2,3,48+(int(ee1/10) mod 10),@charmap01-256,$FF)
dottorikunputchar(3,3,48+(ee1 mod 10),@charmap01-256,$FF)

eep=eep+((ee1 band 8)/8)-((ee1 band 4)/4)
eep=eep+((ee1 band 2)*4)-((ee1 band 1)*8)
ep2=eep band 255
out 0,ep2

dottorikunputchar(1,4,48+(int(ep2/100) mod 10),@charmap01-256,$FF)
dottorikunputchar(2,4,48+(int(ep2/10) mod 10),@charmap01-256,$FF)
dottorikunputchar(3,4,48+(ep2 mod 10),@charmap01-256,$FF)


smsdelay(10000)
eee=eee+1
loop

'-----------------------------------------------------


do:loop


do
for eee=$8000 to $85FF
  seed=smsrnd(seed)
  poke eee,seed

  dottorikunputchar(4,4,eee,@charmap01,0)

  'out 0,eee
  smsdelay(10000)
  next
loop

do:loop

'------------------------------------------------------



